package com.xinya.navigationapplication.fragment

import android.os.Bundle
import android.view.View
import androidx.navigation.fragment.findNavController
import androidx.transition.TransitionInflater
import com.xinya.navigationapplication.R
import kotlinx.android.synthetic.main.fragment_layout_register.view.*

/**
 *
 * @ClassName:      LoginFragment
 * @Description:     java类作用描述
 * @Author:         mhzhuxinya@163.com
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */
class RegisterFragment : BaseFragment() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        sharedElementEnterTransition = TransitionInflater.from(requireContext())
            .inflateTransition(R.transition.shared_image)
    }
    override fun initView(rootView: View) {
        rootView.btnToLoginFragment.setOnClickListener {
            findNavController().navigate(R.id.action_to_fragment_login)
        }

        rootView.btnToForgetFragment.setOnClickListener {
            findNavController().navigate(R.id.action_to_fragment_forget)
        }

        rootView.btnToAgreement.setOnClickListener {
            findNavController().navigate(R.id.action_to_activity_agreement)
        }

        rootView.btnBack.setOnClickListener {
            // 回退 popBackStack() 如果当前的返回栈是空的就会报错，因为栈是空的了，navigateUp() 则不会，还是停留在当前界面
            // navigateUp里面调用的还是popBackStack  所以一般是使用 navigateUp
            findNavController().navigateUp()
            // findNavController().popBackStack()

        }
    }

    override fun getLayoutResId(): Int {
        return R.layout.fragment_layout_register
    }


}